package com.t235.gc.device.service.impl;

import com.t235.gc.entity.DeviceCabinet;
import com.t235.gc.dao.DeviceCabinetDao;
import com.t235.gc.device.service.DeviceCabinetService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * 设备商品柜表(DeviceCabinet)表服务实现类
 *
 * @author makejava
 * @since 2021-03-24 08:45:22
 */
@Service("deviceCabinetService")
public class DeviceCabinetServiceImpl implements DeviceCabinetService {
    @Resource
    private DeviceCabinetDao deviceCabinetDao;

    /**
     * 通过ID查询单条数据
     *
     * @param cabinetid 主键
     * @return 实例对象
     */
    @Override
    public DeviceCabinet queryById(Long cabinetid) {
        return this.deviceCabinetDao.queryById(cabinetid);
    }

    /**
     * 查询多条数据
     *
     * @param offset 查询起始位置
     * @param limit  查询条数
     * @return 对象列表
     */
    @Override
    public List<DeviceCabinet> queryAllByLimit(int offset, int limit) {
        return this.deviceCabinetDao.queryAllByLimit(offset, limit);
    }

    /**
     * 新增数据
     *
     * @param deviceCabinet 实例对象
     * @return 实例对象
     */
    @Override
    public DeviceCabinet insert(DeviceCabinet deviceCabinet) {
        this.deviceCabinetDao.insert(deviceCabinet);
        return deviceCabinet;
    }

    /**
     * 修改数据
     *
     * @param deviceCabinet 实例对象
     * @return 实例对象
     */
    @Override
    public DeviceCabinet update(DeviceCabinet deviceCabinet) {
        this.deviceCabinetDao.update(deviceCabinet);
        return this.queryById(deviceCabinet.getCabinetid());
    }

    /**
     * 通过主键删除数据
     *
     * @param cabinetid 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(Long cabinetid) {
        return this.deviceCabinetDao.deleteById(cabinetid) > 0;
    }
}
